package org.example.emp.pojo;

import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.example.emp.common.IdWorkerUtils;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Data

@NoArgsConstructor
public class Employee {
    @TableId(value = "employee_id")
    private Integer employeeId; // 员工ID
    private Integer departmentId;//部门ID
    private String name; // 姓名，不允许为空
    private String gender; // 性别

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime birthDate; // 出生日期
//    private Department department; // 部门，一对多关系
    private String position; // 职位
    private String contactNumber; // 联系电话
    private Integer status;
    Employee( String name, String gender, LocalDateTime birthDate, String position, String contactNumber, Integer status) {
        this.departmentId =(int) IdWorkerUtils.getInstance().nextId();
        this.name = name;
        this.gender = gender;
        this.birthDate = birthDate;
        this.position = position;
        this.contactNumber = contactNumber;
        this.status = status;
    }
}